<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
pc_base::load_sys_class('form','',0);

class weixin_member extends admin {
	private $weixin_member;
	function __construct() {
        parent::__construct();
		$this->weixin_member = pc_base::load_model('weixin_member_model');
	}
	
	public function list() {
		$name = trim(safe_replace($_GET['name']??''));
		$is_admin = safe_replace($_GET['is_admin']??'');

		$w = '';
		if($is_admin)
			$w .= $w ? "and `is_admin`='$is_admin'" : "`is_admin`='$is_admin'";
		if($name)
			$w .= $w ? "and `name` like '%".$name."%'" : "`name` like '%".$name."%'";

		$datas = $this->weixin_member->listinfo($w,'is_admin asc,id desc',$_GET['page']);
		$pages = $this->weixin_member->pages;
        // $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=epaper&c=index&a=add\', title:\'添加数字报\', width:\'780\', height:\'500\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', '添加数字报');
		include $this->admin_tpl('weixin_member_list');
    }

	public function set_admin() {
		$id = safe_replace($_GET['id']??'');
		$is_admin = safe_replace($_GET['is_admin']??'');

		if($is_admin == '是'){
			$this->weixin_member->update(['is_admin'=>'是'],['id'=>$id]);
		}elseif($is_admin == '否'){
			$this->weixin_member->update(['is_admin'=>'否'],['id'=>$id]);
		}

		showmessage(L('operation_success'),HTTP_REFERER);
	}

}
